home *** CD-ROM | disk | FTP | other *** search
/ Creative Review 28 / Creative-Review-CD-ROM-28.iso / pc / kungfu / assets / game.dir / 00044_Script_boss class < prev    next >
Text File  |  1997-08-08  |  5KB  |  231 lines

  1. -- boss class method
  2. -- --------------------------------------------------
  3.  
  4. property ancestor
  5.  
  6. property huntvector
  7.  
  8. property pattern
  9. property patternindex
  10. property patterncount
  11. -- --------------------------------------------------
  12. global gcell
  13. global gplayer
  14. global gfling
  15. global gkeytomove
  16.  
  17. -- ==================================================
  18. -- new method
  19. -- --------------------------------------------------
  20. on new me, props
  21.   
  22.   minit me, props
  23.   return me
  24.   
  25. end mnew 
  26.  
  27. -- ==================================================
  28. -- minit method
  29. -- --------------------------------------------------
  30. on minit me, props
  31.   
  32.   -- put "in minit boss"
  33.   
  34.   setaprop props, #type, #boss
  35.   setaprop props, #health, 100
  36.   
  37.   set pattern = getaprop ( props, #pattern )
  38.   set patternindex = 0
  39.   set patterncount = count ( pattern )
  40.   
  41.   set ancestor = new ( script "enemy class" , props )
  42.   
  43.   --  put "out minit boss"
  44.   
  45. end minit
  46.  
  47. -- ==================================================
  48. -- mdispose me
  49. -- --------------------------------------------------
  50. on mdispose me
  51.   
  52.   --  put "in mdispose boss class"
  53.   
  54.   mdispose ancestor
  55.   
  56.   set ancestor = 0
  57.   
  58.   --  put "in mdispose boss class"
  59.   
  60. end mdispose me
  61.  
  62. -- ==================================================
  63. -- mstart method
  64. -- --------------------------------------------------
  65. on mstart me
  66.   
  67. --  put "in start boss"
  68.   
  69.   set the nextmove of me = 0
  70.   set the nextmoveflag  of me = false
  71.   
  72.   msetcurrentmove me, #idleleft
  73.   set the direction of me =  #left
  74.   
  75.   set the cell of me =  24
  76.   
  77.   mbatchadd ( gcell, the cell of me, me)
  78.   
  79.   set theloch = mcell2screen ( gcell , the cell of me )
  80.   set theloc = point ( theloch , mgetfloor ( gcell ) - 15 )
  81.   set offset = ( mgetstartoffset ( gcell, the direction of me, the data of me ) ) 
  82.   
  83.   msetloc ( me, theloc + offset )
  84.   
  85. --  put "out start boss"
  86.   
  87. end mstart me
  88.  
  89. -- ==================================================
  90. -- manimfinish method
  91. -- --------------------------------------------------
  92. on manimfinish me
  93.   
  94.   --  put "in manimfinish boss " 
  95.   
  96.   mhide me
  97.   
  98.   mmovefinish me
  99.   
  100.   if (the nextmoveflag  of me) then 
  101.     
  102.     set newmove = (the nextmove of me)
  103.     set the nextmoveflag of me = false
  104.     
  105.   else   set newmove = mthink ( me )
  106.   
  107.   set newmove = mcheckwalk ( me, newmove)
  108.   
  109.   set thekey = mmovetokey ( me, newmove )
  110. --  put "boss move sound: " , the data of me, thekey
  111.   mmove gsound, the data of me, thekey
  112.   
  113.   msetcurrentmove me, newmove
  114.   
  115.   --  put "out manimfinish boss " 
  116.   
  117. end manimfinish
  118. -- ==================================================
  119. -- mthink method
  120. -- --------------------------------------------------
  121. on mthink me
  122.   
  123.   --  put "in mthink boss " 
  124.   
  125.   set newmove = mthink ( ancestor )
  126.   
  127.   if  ( newmove = 0 ) then
  128.     
  129.     set patternindex = patternindex + 1
  130.     if patternindex > patterncount then set patternindex = 1
  131.     set action = getat ( pattern , patternindex )
  132.     
  133.     -- put "action: " , action
  134.     
  135.     case action of
  136.       #attack : set newmove = mattack ( me )
  137.       #hunt:  set newmove = mkeytomove ( me , the direction of me )
  138.       #idle: set newmove = mkeytomove ( me, #idle )
  139.     end case
  140.     
  141.   end if
  142.   
  143.   --  put "newmove: " , newmove
  144.   
  145.   --  put "out mthink boss " 
  146.   
  147.   return newmove
  148.   
  149. end mthink 
  150.  
  151. -- ==================================================
  152. -- mhit method
  153. -- --------------------------------------------------
  154. on mhit me, theloc
  155.   
  156.   --  put "in mhit boss"
  157.   
  158.   if  ilk ( theloc, #point ) then
  159.     
  160.     --    put "fling!",  the currentmove of me
  161.     
  162.     set props = [:]
  163.     set flingloc =  ( the loc of me ) + theloc 
  164.     setaprop props, #loc, flingloc
  165.     setaprop props, #cell, the cell of me
  166.     setaprop props, #direction, the direction of me
  167.     setaprop props, #data, the data of me
  168.     setaprop props, #move, the currentmove of me
  169.     
  170.     mmake gfling props
  171.     
  172.   else if theloc = 0 then
  173.     mdie ( me )
  174.     
  175.   else if theloc = 1 then
  176.     mstream gsound , #dragondie 
  177.     
  178.   end if
  179.   
  180.   --  put "out mhit boss"
  181.   
  182. end mhit 
  183.  
  184. -- ==================================================
  185. -- mdie method
  186. -- --------------------------------------------------
  187. on mdie me
  188.   
  189.   --  put "in mdie boss"
  190.   
  191.   mabort me
  192.   mdraw me
  193.   
  194.   mbossdead gplayer
  195.   mreturnthedead gboss, me
  196.   
  197.   -- mdispose me
  198.   
  199.   --  put "out mdie boss"
  200.   
  201. end mdie
  202.  
  203. -- ==================================================
  204. -- mhurt method
  205. -- --------------------------------------------------
  206. on mhurt me , attackmove, starloc
  207.   
  208.   --  put "in mhurt boss"
  209.   
  210.   set flag = mcheckhurt ( me , attackmove, starloc )
  211.   
  212.   return flag
  213.   
  214.   --  put "out mhurt boss"
  215.   
  216. end mhurt
  217.  
  218. -- ==================================================
  219. -- mstartdie method
  220. -- --------------------------------------------------
  221. on mstartdie me
  222.   
  223.   --  put "in mstartdie boss"
  224.   
  225.   mstream gsound, the data of me
  226.   mbatchdelete gcell, the cell of me , me
  227.   
  228.   --  put "out mstartdie boss"
  229.   
  230. end mstartdie
  231.